//
//  BasicInfoController.m
//  NoNameAmazing
//
//  Created by liuyang on 2017/7/6.
//  Copyright © 2017年 北京执行力科技有限公司. All rights reserved.
//

#import "BasicInfoController.h"
#import "BasicInfoCell.h"
#import "StayMangeController.h"
#import "HomeBodyController.h"
#import "HomeMoneyController.h"
#import "ManageController.h"
#import "CommunicatController.h"

@interface BasicInfoController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView * bTableView;
@property(nonatomic,strong)NSArray * stuInfoArray;

@end

@implementation BasicInfoController
{
 
}
- (void)viewDidLoad {
    [super viewDidLoad];
    if ([[us objectForKey:kRoleid] isEqualToString:@"2"]) {
       self.stuInfoArray = @[@"家庭成员情况",@"家庭经济情况",@"个人通讯"];
    }else{
       self.stuInfoArray = @[@"家庭成员情况",@"家庭经济情况",@"住宿管理",@"个人通讯"];
    }
    
    self.title = @"基本信息";
    
    [self createTableView];
}

-(void)createTableView
{
    _bTableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height-44) style:UITableViewStyleGrouped];
    _bTableView.delegate=self;
    _bTableView.dataSource=self;
    _bTableView.showsVerticalScrollIndicator=NO;
    _bTableView.showsHorizontalScrollIndicator=NO;
    _bTableView.userInteractionEnabled= YES ;
    
    _bTableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    _bTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.view addSubview:_bTableView];
}

#pragma mark - 数据源
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return self.stuInfoArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        BasicInfoCell *cell = [[[NSBundle mainBundle] loadNibNamed:@"BasicInfoCell" owner:nil options:nil] lastObject];
    cell.typeLab.text = self.stuInfoArray[indexPath.row];
        return cell;
    
}

#pragma mark - 代理方法
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return 45;
   
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return 0.001;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
     if ([[us objectForKey:kRoleid] isEqualToString:@"2"]) {
         if(indexPath.row==0){
             HomeBodyController * hbVC = [[HomeBodyController alloc]init];
             hbVC.title = @"家庭成员";
             [self.navigationController pushViewController:hbVC animated:YES];
         }else
             if(indexPath.row==1){
                 HomeMoneyController * hmVC = [[HomeMoneyController alloc]init];
                 hmVC.title = @"家庭经济状况";
                 [self.navigationController pushViewController:hmVC animated:YES];
             }else if (indexPath.row==2){
                 CommunicatController * cVC = [[CommunicatController alloc]init];
                 cVC.title = @"个人通讯";
                 [self.navigationController pushViewController:cVC animated:YES];
                 
             }

     }else{
         if(indexPath.row==0){
             HomeBodyController * hbVC = [[HomeBodyController alloc]init];
             hbVC.title = @"家庭成员";
             [self.navigationController pushViewController:hbVC animated:YES];
         }else
             if(indexPath.row==1){
                 HomeMoneyController * hmVC = [[HomeMoneyController alloc]init];
                 hmVC.title = @"家庭经济状况";
                 [self.navigationController pushViewController:hmVC animated:YES];
             }else if (indexPath.row==2){
                 ManageController * mVC = [[ManageController alloc]init];
                 mVC.title = @"住宿管理";
                 [self.navigationController pushViewController:mVC animated:YES];
                 
             }else{
                 CommunicatController * cVC = [[CommunicatController alloc]init];
                 cVC.title = @"个人通讯";
                 [self.navigationController pushViewController:cVC animated:YES];
        }
     }

     
     
     
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
